class User < ApplicationRecord
  has_many :account_flows, dependent: :destroy
  #before_save { self.email = email.downcase }

  has_secure_password
  validates :password, length: { minimum: 6 }, allow_blank: true
  validates :username, presence: true, uniqueness: true
  VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
  validates :email, presence: true, format: { with: VALID_EMAIL_REGEX },uniqueness: { case_sensitive: false } #不区分大小写
  has_many :ad_groups, dependent: :destroy
  has_many :campaigns, dependent: :destroy
  has_many :landing_pages, dependent: :destroy
  has_many :ad_group_creatives, dependent: :destroy
  has_many :ad_group_rpts, dependent: :destroy
  has_many :campaign_rpts, dependent: :destroy

end
